package com.llsydn.service.local;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * @author lilinshen
 * @title 本地LocalService测试
 * @description 请填写相关描述
 * @date 2018/9/29 9:46
 */
public class LocalService extends Service {
    /**
     *
     * 1.startService
     *     第一次调用：--->构造方法()--->onCreate()--->onStartCommand()
     *     以后调用：  --->onStartCommand()
     *   stopService()--->onDestory()
     *
     * 2.bindService(intent, serviceConnection)
     *     调用：--->构造方法()--->onCreate()--->onBind()--->onServiceConnected()
     *   unbindService(serviceConnection) 中有当前Activity与Service连接
     *     调用：--->onUnbind()--->onDestroy()
     *
     *
     */
    public LocalService() {
        Log.e("TAG", "LocalService()");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("TAG", "onCreate()");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e("TAG", "onDestroy()");
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.e("TAG", "onBind()");
        return new Binder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.e("TAG", "onUnbind()");
        return super.onUnbind(intent);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.e("TAG", "onStartCommand()");
        return super.onStartCommand(intent, flags, startId);
    }
}
